package com.atguigu;

import com.atguigu.pojo.User;
import com.atguigu.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class UserMapperTest2 {
    @Autowired
    private UserService userService;

    @Test
    public void test1(){
        User user1 = userService.getById(2);
        user1.setName("xiaohu");

        User user2 = new User();
        user2.setName("list");
        user2.setAge(17);
        user2.setEmail("132456");

        boolean b = userService.saveOrUpdate(user1);
        boolean b1 = userService.saveOrUpdate(user2);


    }

    @Test
    public void test2(){
        User user = new User(null,"dongdong",49,"123456789");
        User user2 = new User(null,"dongdong2",49,"123456789");
        List<User> users = List.of(user2, user);
        userService.saveBatch(users);


    }
}
